
*****************************************************************************
* 																			*
*			Campaign Panel Book Chapter 4 - Four types of campaign trajectories								*		
*																			*
*****************************************************************************


* Create new voting intention variable containing the summary of "others"

foreach var in a b{
foreach num of numlist 1/7{

gen `var'_wabsrestr`num' = `var'_wabsfull`num'
recode `var'_wabsrestr`num' (8/801 803=801) (993/998=888)
}
}

*Exclusive non-voters
foreach var in a b{
foreach num of numlist 1/7{

gen `var'_wabsrestr_novote`num' = `var'_wabsrestr`num'
recode `var'_wabsrestr_novote`num' (8/801=801) (900/1000=.)
}
}

***In 2009 there is a ambiguous coding of "don't know". As we declare "don't know" as undecided, the respective code will be treated as missing in wave 7

recode a_wabsrestr_novote7 (888=.)

* Assing the same specifications to W2-starters as are assigned for W1
* The W2-starters cannot simply be integrated into the model, this does not work for the crosstabulation. 
* Possibilities:
* 1. Transfer of indicators from wave 1 (results in overestimation of volatility)
* 2. Separate calculation of volatility for W2 starters 2009 (inefficient and not feasible)
* 3. Exclude wave 1 completely (theoretically and empirically problematic)

gen a_wabsrestr1_w2 = a_wabsrestr1
replace a_wabsrestr1_w2 = a_wabsrestr2 if a_w1==0

gen a_wabsrestr_novote1_w2 = a_wabsrestr_novote1
replace a_wabsrestr_novote1_w2 = a_wabsrestr_novote2 if a_w1==0


* 2009 / 2013 simple coding of swing voters for all swing voters (including change from indecision to 
* vote intention or change from abstention to indecision or vote intention)


***************************************
* Simple "changers" (in the final crosstab for all waves without w2 starters, since no participation in wave 1)
***************************************


foreach var in a b{
gen `var'_wabschange12 = .
replace `var'_wabschange12 = 0 if `var'_wabsrestr1==`var'_wabsrestr2 & `var'_wabsrestr1!=.
replace `var'_wabschange12 = 1 if `var'_wabsrestr1!=`var'_wabsrestr2 & `var'_wabsrestr1!=. & `var'_wabsrestr2!=.

gen `var'_wabschange23 = .
replace `var'_wabschange23 = 0 if `var'_wabsrestr2==`var'_wabsrestr3 & `var'_wabsrestr2!=.
replace `var'_wabschange23 = 1 if `var'_wabsrestr2!=`var'_wabsrestr3 & `var'_wabsrestr2!=. & `var'_wabsrestr3!=.

gen `var'_wabschange34 = .
replace `var'_wabschange34 = 0 if `var'_wabsrestr3==`var'_wabsrestr4 & `var'_wabsrestr3!=.
replace `var'_wabschange34 = 1 if `var'_wabsrestr3!=`var'_wabsrestr4 & `var'_wabsrestr3!=. & `var'_wabsrestr4!=.

gen `var'_wabschange45 = .
replace `var'_wabschange45 = 0 if `var'_wabsrestr4==`var'_wabsrestr5 & `var'_wabsrestr4!=.
replace `var'_wabschange45 = 1 if `var'_wabsrestr4!=`var'_wabsrestr5 & `var'_wabsrestr4!=. & `var'_wabsrestr5!=.

gen `var'_wabschange56 = .
replace `var'_wabschange56 = 0 if `var'_wabsrestr5==`var'_wabsrestr6 & `var'_wabsrestr5!=.
replace `var'_wabschange56 = 1 if `var'_wabsrestr5!=`var'_wabsrestr6 & `var'_wabsrestr5!=. & `var'_wabsrestr6!=.

gen `var'_wabschange67 = .
replace `var'_wabschange67 = 0 if `var'_wabsrestr6==`var'_wabsrestr7 & `var'_wabsrestr6!=.
replace `var'_wabschange67 = 1 if `var'_wabsrestr6!=`var'_wabsrestr7 & `var'_wabsrestr6!=. & `var'_wabsrestr7!=.

}



foreach var in a b{
gen `var'_anzahlwechsel = `var'_wabschange12 + `var'_wabschange23 + `var'_wabschange34 + `var'_wabschange45 + `var'_wabschange56 + `var'_wabschange67
}

tab a_anzahlwechsel [aweight=a_weight]
tab b_anzahlwechsel [aweight=b_weight]



*Excluding non-voters
foreach var in a b{
gen `var'_wabschange_novote12 = .
replace `var'_wabschange_novote12 = 0 if `var'_wabsrestr_novote1==`var'_wabsrestr_novote2 & `var'_wabsrestr_novote1!=.
replace `var'_wabschange_novote12 = 1 if `var'_wabsrestr_novote1!=`var'_wabsrestr_novote2 & `var'_wabsrestr_novote1!=. & `var'_wabsrestr_novote2!=.

gen `var'_wabschange_novote23 = .
replace `var'_wabschange_novote23 = 0 if `var'_wabsrestr_novote2==`var'_wabsrestr_novote3 & `var'_wabsrestr_novote2!=.
replace `var'_wabschange_novote23 = 1 if `var'_wabsrestr_novote2!=`var'_wabsrestr_novote3 & `var'_wabsrestr_novote2!=. & `var'_wabsrestr_novote3!=.

gen `var'_wabschange_novote34 = .
replace `var'_wabschange_novote34 = 0 if `var'_wabsrestr_novote3==`var'_wabsrestr_novote4 & `var'_wabsrestr_novote3!=.
replace `var'_wabschange_novote34 = 1 if `var'_wabsrestr_novote3!=`var'_wabsrestr_novote4 & `var'_wabsrestr_novote3!=. & `var'_wabsrestr_novote4!=.

gen `var'_wabschange_novote45 = .
replace `var'_wabschange_novote45 = 0 if `var'_wabsrestr_novote4==`var'_wabsrestr_novote5 & `var'_wabsrestr_novote4!=.
replace `var'_wabschange_novote45 = 1 if `var'_wabsrestr_novote4!=`var'_wabsrestr_novote5 & `var'_wabsrestr_novote4!=. & `var'_wabsrestr_novote5!=.

gen `var'_wabschange_novote56 = .
replace `var'_wabschange_novote56 = 0 if `var'_wabsrestr_novote5==`var'_wabsrestr_novote6 & `var'_wabsrestr_novote5!=.
replace `var'_wabschange_novote56 = 1 if `var'_wabsrestr_novote5!=`var'_wabsrestr_novote6 & `var'_wabsrestr_novote5!=. & `var'_wabsrestr_novote6!=.

gen `var'_wabschange_novote67 = .
replace `var'_wabschange_novote67 = 0 if `var'_wabsrestr_novote6==`var'_wabsrestr_novote7 & `var'_wabsrestr_novote6!=.
replace `var'_wabschange_novote67 = 1 if `var'_wabsrestr_novote6!=`var'_wabsrestr_novote7 & `var'_wabsrestr_novote6!=. & `var'_wabsrestr_novote7!=.

}

foreach var in a b{
gen `var'_anzahlwechsel_novote = `var'_wabschange_novote12 + `var'_wabschange_novote23 + `var'_wabschange_novote34 + `var'_wabschange_novote45 + `var'_wabschange_novote56 + `var'_wabschange_novote67
}

tab a_anzahlwechsel_novote [aweight=a_weight]
tab b_anzahlwechsel_novote [aweight=b_weight]

***************************************
* Simple "changers" (including W2-starters)
***************************************

gen a_wabschange12_w2 = .
replace a_wabschange12_w2 = 0 if a_wabsrestr1_w2==a_wabsrestr2 & a_wabsrestr1_w2!=.
replace a_wabschange12_w2 = 1 if a_wabsrestr1_w2!=a_wabsrestr2 & a_wabsrestr1_w2!=. & a_wabsrestr2!=.

gen a_anzahlwechsel_w2 = a_wabschange12_w2 + a_wabschange23 + a_wabschange34 + a_wabschange45 + a_wabschange56 + a_wabschange67

tab a_anzahlwechsel [aweight=a_weight]
tab a_anzahlwechsel_w2 [aweight=a_weight]
tab b_anzahlwechsel [aweight=b_weight]

*Excluding non-voters

gen a_wabschange_novote12_w2 = .
replace a_wabschange_novote12_w2 = 0 if a_wabsrestr_novote1_w2==a_wabsrestr_novote2 & a_wabsrestr_novote1_w2!=.
replace a_wabschange_novote12_w2 = 1 if a_wabsrestr_novote1_w2!=a_wabsrestr_novote2 & a_wabsrestr_novote1_w2!=. & a_wabsrestr_novote2!=.

gen a_anzahlwechsel_novote_w2 = a_wabschange_novote12_w2 + a_wabschange_novote23 + a_wabschange_novote34 + a_wabschange_novote45 + a_wabschange_novote56 + a_wabschange_novote67

tab a_anzahlwechsel_novote [aweight=a_weight]
tab a_anzahlwechsel_novote_w2 [aweight=a_weight]
tab b_anzahlwechsel_novote [aweight=b_weight]






***************************************
*Lazarsfeld-types without non-voters
***************************************


foreach var in b {
gen `var'_lazarstyp_novote_cry=.

*** Partisans (for all parties including stable "others")
replace `var'_lazarstyp_novote_cry=1 if `var'_wabsrestr_novote1==`var'_wabsrestr_novote2 & `var'_wabsrestr_novote2==`var'_wabsrestr_novote3 & `var'_wabsrestr_novote3==`var'_wabsrestr_novote4 & `var'_wabsrestr_novote4==`var'_wabsrestr_novote5 & `var'_wabsrestr_novote5==`var'_wabsrestr_novote6  & `var'_wabsrestr_novote6==`var'_wabsrestr_novote7 & `var'_wabsrestr_novote7<=801

*** Crystalizer (a voting decision can only crystallize for undecided respondents. This decision does not necessarily have to remain constant)
replace `var'_lazarstyp_novote_cry=2 if `var'_wabsrestr_novote1==888 & `var'_wabsrestr_novote2==888 & `var'_wabsrestr_novote3==888 & `var'_wabsrestr_novote4==888 & `var'_wabsrestr_novote5==888  & `var'_wabsrestr_novote6==888 & `var'_wabsrestr_novote7<888
replace `var'_lazarstyp_novote_cry=2 if `var'_wabsrestr_novote1==888 & `var'_wabsrestr_novote2==888 & `var'_wabsrestr_novote3==888 & `var'_wabsrestr_novote4==888 & `var'_wabsrestr_novote5==888  & `var'_wabsrestr_novote6<888   & `var'_wabsrestr_novote7<888
replace `var'_lazarstyp_novote_cry=2 if `var'_wabsrestr_novote1==888 & `var'_wabsrestr_novote2==888 & `var'_wabsrestr_novote3==888 & `var'_wabsrestr_novote4==888 & `var'_wabsrestr_novote5<888 & `var'_wabsrestr_novote6<888  & `var'_wabsrestr_novote7<888
replace `var'_lazarstyp_novote_cry=2 if `var'_wabsrestr_novote1==888 & `var'_wabsrestr_novote2==888 & `var'_wabsrestr_novote3==888 & `var'_wabsrestr_novote4<888  & `var'_wabsrestr_novote5<888 & `var'_wabsrestr_novote6<888  & `var'_wabsrestr_novote7<888
replace `var'_lazarstyp_novote_cry=2 if `var'_wabsrestr_novote1==888 & `var'_wabsrestr_novote2==888 & `var'_wabsrestr_novote3<888 & `var'_wabsrestr_novote4<888  & `var'_wabsrestr_novote5<888 & `var'_wabsrestr_novote6<888   & `var'_wabsrestr_novote7<888
replace `var'_lazarstyp_novote_cry=2 if `var'_wabsrestr_novote1==888 & `var'_wabsrestr_novote2<888 & `var'_wabsrestr_novote3<888 & `var'_wabsrestr_novote4<888  & `var'_wabsrestr_novote5<888 & `var'_wabsrestr_novote6<888   & `var'_wabsrestr_novote7<888

***Waverer (respondents name the same party in wave 7 as in wave 1, but answers in intermediate waves differ)
replace `var'_lazarstyp_novote_cry=3 if `var'_wabsrestr_novote1==`var'_wabsrestr_novote7 & (`var'_wabsrestr_novote1!=`var'_wabsrestr_novote2 | `var'_wabsrestr_novote1!=`var'_wabsrestr_novote3 | `var'_wabsrestr_novote1!=`var'_wabsrestr_novote4 | `var'_wabsrestr_novote1!=`var'_wabsrestr_novote5 | `var'_wabsrestr_novote1!=`var'_wabsrestr_novote6) & `var'_wabsrestr_novote7<888

***Party Changer (respondents change their voting intention between waves 1 and 7)
replace `var'_lazarstyp_novote_cry=4 if `var'_wabsrestr_novote1<888 & `var'_wabsrestr_novote7<888 & `var'_wabsrestr_novote1!=`var'_wabsrestr_novote7

***Unsure Crystalizer
replace `var'_lazarstyp_novote_cry=2 if `var'_lazarstyp_novote_cry==. & `var'_anzahlwechsel_novote!=.

replace `var'_lazarstyp_novote_cry=. if `var'_anzahlwechsel_novote==.

}

*Including W2-starters
gen a_lazarstyp_novote_cry=.

*** Partisans (for all parties including stable "others")
replace a_lazarstyp_novote_cry=1 if a_wabsrestr_novote1_w2==a_wabsrestr_novote2 & a_wabsrestr_novote2==a_wabsrestr_novote3 & a_wabsrestr_novote3==a_wabsrestr_novote4 & a_wabsrestr_novote4==a_wabsrestr_novote5 & a_wabsrestr_novote5==a_wabsrestr_novote6  & a_wabsrestr_novote6==a_wabsrestr_novote7 & a_wabsrestr_novote7<=801

*** Crystalizer (a voting decision can only crystallize for undecided respondents. This decision does not necessarily have to remain constant)
replace a_lazarstyp_novote_cry=2 if a_wabsrestr_novote1_w2==888 & a_wabsrestr_novote2==888 & a_wabsrestr_novote3==888 & a_wabsrestr_novote4==888 & a_wabsrestr_novote5==888  & a_wabsrestr_novote6==888 & a_wabsrestr_novote7<888
replace a_lazarstyp_novote_cry=2 if a_wabsrestr_novote1_w2==888 & a_wabsrestr_novote2==888 & a_wabsrestr_novote3==888 & a_wabsrestr_novote4==888 & a_wabsrestr_novote5==888  & a_wabsrestr_novote6<888   & a_wabsrestr_novote7<888
replace a_lazarstyp_novote_cry=2 if a_wabsrestr_novote1_w2==888 & a_wabsrestr_novote2==888 & a_wabsrestr_novote3==888 & a_wabsrestr_novote4==888 & a_wabsrestr_novote5<888 & a_wabsrestr_novote6<888  & a_wabsrestr_novote7<888
replace a_lazarstyp_novote_cry=2 if a_wabsrestr_novote1_w2==888 & a_wabsrestr_novote2==888 & a_wabsrestr_novote3==888 & a_wabsrestr_novote4<888  & a_wabsrestr_novote5<888 & a_wabsrestr_novote6<888  & a_wabsrestr_novote7<888
replace a_lazarstyp_novote_cry=2 if a_wabsrestr_novote1_w2==888 & a_wabsrestr_novote2==888 & a_wabsrestr_novote3<888 & a_wabsrestr_novote4<888  & a_wabsrestr_novote5<888 & a_wabsrestr_novote6<888   & a_wabsrestr_novote7<888
replace a_lazarstyp_novote_cry=2 if a_wabsrestr_novote1_w2==888 & a_wabsrestr_novote2<888 & a_wabsrestr_novote3<888 & a_wabsrestr_novote4<888  & a_wabsrestr_novote5<888 & a_wabsrestr_novote6<888   & a_wabsrestr_novote7<888

***Waverer (respondents name the same party in wave 7 as in wave 1, but answers in intermediate waves differ)
replace a_lazarstyp_novote_cry=3 if a_wabsrestr_novote1_w2==a_wabsrestr_novote7 & (a_wabsrestr_novote1_w2!=a_wabsrestr_novote2 | a_wabsrestr_novote1_w2!=a_wabsrestr_novote3 | a_wabsrestr_novote1_w2!=a_wabsrestr_novote4 | a_wabsrestr_novote1_w2!=a_wabsrestr_novote5 | a_wabsrestr_novote1_w2!=a_wabsrestr_novote6) & a_wabsrestr_novote7<888

***Party Changer (respondents change their voting intention between waves 1 and 7)
replace a_lazarstyp_novote_cry=4 if a_wabsrestr_novote1_w2<888 & a_wabsrestr_novote7<888 & a_wabsrestr_novote1_w2!=a_wabsrestr_novote7

***Unsure Crystalizer (also coded as Crystalizers)
replace a_lazarstyp_novote_cry=2 if a_lazarstyp_novote_cry==. & a_anzahlwechsel_novote_w2!=.

replace a_lazarstyp_novote_cry=. if a_anzahlwechsel_novote_w2==.

label define lazar2 1 "Partisan" 2 "Crystalizer" 3 "Waverer" 4 "Party Changer"

label value a_lazarstyp_novote_cry b_lazarstyp_novote_cry lazar2

tab a_lazarstyp_novote_cry [aweight=a_weight]
tab b_lazarstyp_novote_cry [aweight=b_weight]


foreach year in a b {
bysort `year'_wabsrestr_novote7: tab `year'_lazarstyp_novote_cry [aw=`year'_weight]
}



save "${data}\data2009_2013 participants 7 waves.dta", replace
